package com.dyz.service.impl;

import com.dyz.domain.SysMenu;
import com.dyz.mapper.SysMenuMapper;
import com.dyz.service.ISysMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dyz.service.ISysRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 系统菜单 服务实现类
 * </p>
 *
 * @author dyz
 * @since 2025-04-19
 */
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
    @Resource
    private SysMenuMapper sysMenuMapper;
    @Resource
    private ISysRoleService sysRoleService;

    @Override
    public List<SysMenu> selectMenuByUserId(Long userId) {
        // 超级管理员
        if(sysRoleService.isSuperAdmin(userId)){
            return list();
        }
        //普通管理员查询对应的权限菜单
        return sysMenuMapper.selectMenuByUserId(userId);
    }
}
